@use "../core/color";
@use "../core/layout";
@use "../core/typography";

// Input field in the nav bar for searching annotations
// ----------------------------------------------------
// Specs: https://trello.com/c/atjT8T9p

.search-bar {
  border: 1px solid color.$grey-3;
  border-radius: 2px;
  display: flex;
  flex-wrap: wrap;

  // scope absolute positioned elements
  position: relative;
}

.search-bar__input {
  flex: 1;

  border: none;

  // Add spacing to left of input field for search icon
  padding-left: 7px;
  padding-top: 18px;
  padding-bottom: 18px;
  padding-right: 3px;

  // prevent the search input from being squashed
  min-width:30%;

  .env-js-capable & {
    visibility: hidden;
  }

  .env-js-timeout & {
    visibility: visible;
  }
}

.search-bar__input:hover,
.search-bar__input:focus {
  border-color: color.$grey-4;
  outline: none;
}

.search-bar__lozenges {
  // offset is the width of the magnifying glass icon left of input
  width: calc(100% - 24px);
  display: flex;
  flex-wrap: wrap;
}

.search-bar__icon {
  flex-shrink: 0;
  height: 14px;
  margin-left: 7px;
  margin-top: 18px;
  color: color.$grey-5;
}

.search-bar__input:hover + .search-bar__icon,
.search-bar__input:focus + .search-bar__icon {
  color: color.$grey-6;
}

.search-bar__dropdown-menu-container {
  background: white;
  border: 1px solid color.$grey-2;
  border-top: none;
  box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.15);
  color: color.$grey-4;
  display: none;
  padding: 20px 0 0 0;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 1px;
  width: 100%;
  z-index: layout.$zindex-dropdown-menu;
  max-width: 650px;
}

.search-bar__dropdown-menu-header {
  margin: 0 30px 7px 30px;
}

.search-bar__dropdown-menu-item {
  padding: 6px 30px 6px 30px;
  cursor: pointer;
}

.search-bar__dropdown-menu-item:last-child {
  margin-bottom: 14px;
}

.js-search-bar-dropdown-menu-item--active {
  background-color: color.$grey-2;
}

.search-bar__dropdown-menu-title {
  color: color.$grey-6;
  font-weight: bold;
}

.search-bar__dropdown-menu-relationship {
  margin-left: 5px;
  color: color.$grey-4;
  font-weight: bold;
}

.search-bar__dropdown-menu-explanation {
  font-style: italic;
}

.search-bar__dropdown-menu-container.is-open {
  display: block;
}

.search-bar__dropdown-menu-item.is-hidden {
  display: none;
}

@include layout.touch-input {
  .search-bar__input {
    font-size: typography.$touch-input-font-size;
  }
}
